package com.kuangstudy.collection.list;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * ClassName: MyException
 * date: 2021/07/12 12:04:37
 *
 * @author zlk
 */
public class Demo {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
        collection.add("水果1");
        collection.add("水果2");
        collection.add("水果3");
        collection.add("水果4");
        Iterator iterator = collection.iterator();
        /*迭代器进行遍历,可以用迭代器删除集合元素*/
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
//            iterator.remove();
        }
        System.out.println(collection.size());
        System.out.println(collection.contains("水果1"));
        System.out.println(collection.isEmpty());

    }
}
